<!DOCTYPE html><html><head>
      <title>python&#x67F1;&#x72B6;&#x56FE;&#x7BC7;</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///c:\Users\Kikyo\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.6.8\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
      
      
      
      
      
      
      
      
      
      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;background-color:#f0f0f0;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.markdown-preview .md-toc{padding:0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link p,.markdown-preview .md-toc .md-toc-link-wrapper .md-toc-link div{display:inline}.markdown-preview .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc{padding:0 16px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link{display:inline;padding:.25rem 0}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link p,html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper .md-toc-link div{display:inline}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc .md-toc .md-toc-link-wrapper.highlighted .md-toc-link{font-weight:800}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  300px/2);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <p>&#x67F1;&#x5F62;&#x56FE;&#x7BC7;</p>

<div class="md-toc">
<div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:18px">
          <a href="#&#x76F8;&#x5173;&#x5E93;&#x548C;&#x4F5C;&#x56FE;&#x4E3B;&#x9898;" class="md-toc-link">
            <p>&#x76F8;&#x5173;&#x5E93;&#x548C;&#x4F5C;&#x56FE;&#x4E3B;&#x9898;</p>

          </a></div><details style="padding:0;;padding-left:0px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x7B80;&#x5355;&#x67F1;&#x5F62;&#x56FE;&#x7684;&#x7ED8;&#x5236;" class="md-toc-link"><p>&#x7B80;&#x5355;&#x67F1;&#x5F62;&#x56FE;&#x7684;&#x7ED8;&#x5236;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;" class="md-toc-link">
            <p>&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#matplotlib&#x7ED8;&#x5236;" class="md-toc-link">
            <p>matplotlib&#x7ED8;&#x5236;</p>

          </a></div>
        </div>
      </details>
    <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:18px">
          <a href="#sns&#x7684;&#x5B9E;&#x73B0;" class="md-toc-link">
            <p>sns&#x7684;&#x5B9E;&#x73B0;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:18px">
          <a href="#&#x67F1;&#x72B6;&#x56FE;&#x8FDB;&#x9636;" class="md-toc-link">
            <p>&#x67F1;&#x72B6;&#x56FE;&#x8FDB;&#x9636;</p>

          </a></div><details style="padding:0;;padding-left:0px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x6DFB;&#x52A0;&#x8BEF;&#x5DEE;&#x68D2;" class="md-toc-link"><p>&#x6DFB;&#x52A0;&#x8BEF;&#x5DEE;&#x68D2;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;-1" class="md-toc-link">
            <p>&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#matplotlib&#x7ED8;&#x5236;-1" class="md-toc-link">
            <p>matplotlib&#x7ED8;&#x5236;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#sns&#x7ED8;&#x5236;" class="md-toc-link">
            <p>sns&#x7ED8;&#x5236;</p>

          </a></div>
        </div>
      </details>
    <details style="padding:0;;padding-left:0px;" open>
        <summary class="md-toc-link-wrapper">
          <a href="#&#x5206;&#x7EC4;&#x67F1;&#x72B6;&#x56FE;" class="md-toc-link"><p>&#x5206;&#x7EC4;&#x67F1;&#x72B6;&#x56FE;</p>
</a>
          </summary>
        <div>
          <div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;-2" class="md-toc-link">
            <p>&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#matplotlib&#x7ED8;&#x5236;-2" class="md-toc-link">
            <p>matplotlib&#x7ED8;&#x5236;</p>

          </a></div><div class="md-toc-link-wrapper" style="padding:0;;display:list-item;list-style:square;margin-left:42px">
          <a href="#sns&#x7ED8;&#x5236;-1" class="md-toc-link">
            <p>sns&#x7ED8;&#x5236;</p>

          </a></div>
        </div>
      </details>
    
</div>
<h2 class="mume-header" id="%E7%9B%B8%E5%85%B3%E5%BA%93%E5%92%8C%E4%BD%9C%E5%9B%BE%E4%B8%BB%E9%A2%98">&#x76F8;&#x5173;&#x5E93;&#x548C;&#x4F5C;&#x56FE;&#x4E3B;&#x9898;</h2>

<pre data-role="codeBlock" data-info="python" class="language-python"><span class="token comment">#rom pdb import line_prefix</span>
<span class="token comment">#from turtle import title</span>
<span class="token keyword keyword-import">import</span> numpy <span class="token keyword keyword-as">as</span> np <span class="token comment"># &#x5BFC;&#x5165;&#x79D1;&#x5B66;&#x8BA1;&#x7B97;&#x5E93;</span>
<span class="token keyword keyword-import">import</span> pandas <span class="token keyword keyword-as">as</span> pd
<span class="token keyword keyword-import">import</span> matplotlib <span class="token keyword keyword-as">as</span> mpl <span class="token comment">#&#x5BFC;&#x5165;&#x53EF;&#x89C6;&#x5316;&#x5E93;</span>
<span class="token keyword keyword-import">import</span> matplotlib<span class="token punctuation">.</span>pyplot <span class="token keyword keyword-as">as</span> plt
<span class="token keyword keyword-import">import</span> seaborn <span class="token keyword keyword-as">as</span> sns <span class="token comment"># &#x5BFC;&#x5165;&#x53EF;&#x89C6;&#x5316;&#x5E93;seaborn</span>
sns<span class="token punctuation">.</span>set_theme<span class="token punctuation">(</span>context<span class="token operator">=</span><span class="token string">&apos;notebook&apos;</span><span class="token punctuation">,</span> style<span class="token operator">=</span><span class="token string">&apos;ticks&apos;</span><span class="token punctuation">,</span> palette<span class="token operator">=</span><span class="token string">&apos;deep&apos;</span><span class="token punctuation">,</span> font_scale<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">,</span> color_codes<span class="token operator">=</span><span class="token boolean">True</span><span class="token punctuation">,</span> rc<span class="token operator">=</span><span class="token boolean">None</span> <span class="token punctuation">)</span>
sns<span class="token punctuation">.</span>set_style<span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&apos;font.sans-serif&apos;</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token string">&apos;simsun&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;serif&apos;</span><span class="token punctuation">]</span><span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token comment"># &#x9002;&#x914D;&#x4E2D;&#x82F1;&#x6587;</span>
<span class="token comment">#plt.rcParams[&apos;xtick.direction&apos;] = &apos;in&apos; # &#x523B;&#x5EA6;&#x671D;&#x5185;</span>
<span class="token comment">#plt.rcParams[&apos;ytick.direction&apos;] = &apos;in&apos;</span>
<span class="token comment">#plt.rcParams[&apos;font.sans-serif&apos;] = &apos;simsun&apos; # &#x89E3;&#x51B3;&#x4E2D;&#x6587;&#x663E;&#x793A;</span>
plt<span class="token punctuation">.</span>rcParams<span class="token punctuation">[</span><span class="token string">&apos;axes.unicode_minus&apos;</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token boolean">False</span> <span class="token comment"># &#x89E3;&#x51B3;&#x7B26;&#x53F7;&#x65E0;&#x6CD5;&#x663E;&#x793A;</span>
</pre><h2 class="mume-header" id="%E7%AE%80%E5%8D%95%E6%9F%B1%E5%BD%A2%E5%9B%BE%E7%9A%84%E7%BB%98%E5%88%B6">&#x7B80;&#x5355;&#x67F1;&#x5F62;&#x56FE;&#x7684;&#x7ED8;&#x5236;</h2>

<h3 class="mume-header" id="%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E9%9B%86">&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;</h3>

<pre data-role="codeBlock" data-info="python" class="language-python"><span class="token comment"># &#x901A;&#x8FC7;&#x5B57;&#x5178;&#x521B;&#x5EFA;DataFrame</span>
df <span class="token operator">=</span> pd<span class="token punctuation">.</span>DataFrame<span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token string">&apos;group&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group2&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group3&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group4&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;meanvalue&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">18</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;sdvalue&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">2.4</span><span class="token punctuation">,</span> <span class="token number">2.8</span><span class="token punctuation">]</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token comment">#df</span>
</pre><h3 class="mume-header" id="matplotlib%E7%BB%98%E5%88%B6">matplotlib&#x7ED8;&#x5236;</h3>

<pre data-role="codeBlock" data-info="python" class="language-python">fig<span class="token punctuation">,</span> ax <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span>figsize <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
ax<span class="token punctuation">.</span>bar<span class="token punctuation">(</span>df<span class="token punctuation">.</span>group<span class="token punctuation">,</span> df<span class="token punctuation">.</span>meanvalue<span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span>
color <span class="token operator">=</span> <span class="token string">&apos;grey&apos;</span><span class="token punctuation">,</span> linewidth <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">)</span>
ax<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> yticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">,</span> 
xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>title<span class="token punctuation">(</span><span class="token string">&apos;&#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE;&apos;</span><span class="token punctuation">)</span>
<span class="token comment">#plt.legend(title = &apos;treatment&apos;)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-3-1.png" width="384">
<p>Tips: &#x56E0;&#x4E3A;python&#x662F;&#x4ECE;0&#x5F00;&#x59CB;&#x8BA1;&#x6570;&#x7684;&#xFF0C;&#x6240;&#x4EE5;group1&#x5373;&#x7B2C;&#x4E00;&#x4E2A;&#x67F1;&#x5B50;&#x662F;&#x5728;0&#x523B;&#x5EA6;&#x4E0A;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x4E3A;&#x4E86;&#x80FD;&#x591F;&#x5C55;&#x73B0;&#x5168;&#x90E8;&#x7684;&#x5185;&#x5BB9;&#xFF0C;x&#x53D6;&#x503C;&#x8303;&#x56F4;&#x8981;&#x5C0F;&#x4E8E;0&#x3002;</p>
<p>&#x5982;&#x679C;&#x8981;&#x7ED9;&#x67F1;&#x72B6;&#x56FE;&#x6DFB;&#x52A0;&#x5404;&#x7C7B;&#x989C;&#x8272;&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8D4B;&#x503C;&#x7684;&#x5F62;&#x5F0F;&#x5C55;&#x73B0;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="python" class="language-python">bar_color <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">&apos;red&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;orange&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;blue&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;green&apos;</span><span class="token punctuation">]</span>
fig<span class="token punctuation">,</span> ax <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span>figsize <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
ax<span class="token punctuation">.</span>bar<span class="token punctuation">(</span>df<span class="token punctuation">.</span>group<span class="token punctuation">,</span> df<span class="token punctuation">.</span>meanvalue<span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span>
color <span class="token operator">=</span> bar_color<span class="token punctuation">,</span> linewidth <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">)</span>
ax<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> yticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">,</span> xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>title<span class="token punctuation">(</span><span class="token string">&apos;&#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE;&apos;</span><span class="token punctuation">)</span>
<span class="token comment">#plt.legend(title = &apos;Group&apos;)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-4-3.png" width="384">
<h2 class="mume-header" id="sns%E7%9A%84%E5%AE%9E%E7%8E%B0">sns&#x7684;&#x5B9E;&#x73B0;</h2>

<pre data-role="codeBlock" data-info="python" class="language-python">f<span class="token punctuation">,</span> ax <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span>figsize<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
sns<span class="token punctuation">.</span>barplot<span class="token punctuation">(</span>x<span class="token operator">=</span><span class="token string">&quot;group&quot;</span><span class="token punctuation">,</span> y<span class="token operator">=</span><span class="token string">&quot;meanvalue&quot;</span><span class="token punctuation">,</span> color <span class="token operator">=</span> <span class="token string">&apos;grey&apos;</span><span class="token punctuation">,</span>edgecolor <span class="token operator">=</span><span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span>linewidth<span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">,</span> data<span class="token operator">=</span>df<span class="token punctuation">)</span>
ax<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> yticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">,</span> 
xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>title<span class="token punctuation">(</span><span class="token string">&apos;&#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE;&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-5-5.png" width="384">
<p>&#x4E0D;&#x540C;&#x989C;&#x8272;&#x7684;&#x5B9E;&#x73B0;&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="python" class="language-python">bar_color <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">&apos;red&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;orange&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;blue&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;green&apos;</span><span class="token punctuation">]</span>
f<span class="token punctuation">,</span> ax <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span>figsize<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
sns<span class="token punctuation">.</span>barplot<span class="token punctuation">(</span>x<span class="token operator">=</span><span class="token string">&quot;group&quot;</span><span class="token punctuation">,</span> y<span class="token operator">=</span><span class="token string">&quot;meanvalue&quot;</span><span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span> palette <span class="token operator">=</span> sns<span class="token punctuation">.</span>color_palette<span class="token punctuation">(</span>bar_color<span class="token punctuation">)</span><span class="token punctuation">,</span>linewidth<span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">,</span> data<span class="token operator">=</span>df<span class="token punctuation">)</span>
ax<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> yticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">,</span> 
xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>title<span class="token punctuation">(</span><span class="token string">&apos;&#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE;&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-6-7.png" width="384">
<p>&#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x6BD4;&#x8F83;&#x6709;&#x610F;&#x601D;&#x7684;&#xFF0C;matplotlib&#x548C;seaborn&#x7ED8;&#x5236;&#x6C34;&#x5E73;&#x67F1;&#x72B6;&#x56FE;&#x7684;&#x95EE;&#x9898;&#x4E0A;&#xFF0C;&#x7565;&#x6709;&#x4E0D;&#x540C;&#x3002;</p>
<pre data-role="codeBlock" data-info="python" class="language-python">bar_color <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">&apos;red&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;orange&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;blue&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;green&apos;</span><span class="token punctuation">]</span>
<span class="token comment"># &#x7ED8;&#x5236;&#x4E00;&#x4E2A;&#x7EC4;&#x56FE;&#x5171;&#x4EAB;y&#x8F74;</span>
f<span class="token punctuation">,</span> <span class="token punctuation">(</span>ax1<span class="token punctuation">,</span> ax2<span class="token punctuation">)</span> <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> figsize<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> sharey <span class="token operator">=</span> <span class="token boolean">True</span><span class="token punctuation">)</span>
<span class="token comment"># ax1&#x4E3A;matplotlib&#x7ED8;&#x5236;</span>
ax1<span class="token punctuation">.</span>barh<span class="token punctuation">(</span>df<span class="token punctuation">.</span>group<span class="token punctuation">,</span> df<span class="token punctuation">.</span>meanvalue<span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span>
color <span class="token operator">=</span> bar_color<span class="token punctuation">,</span> linewidth <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> height <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">)</span>
ax1<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> xticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span> xlabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">,</span> title <span class="token operator">=</span> <span class="token string">&apos;&#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE; by matplotlib&apos;</span><span class="token punctuation">)</span>
<span class="token comment"># ax2&#x4E3A;seaborn&#x7ED8;&#x5236;</span>
sns<span class="token punctuation">.</span>barplot<span class="token punctuation">(</span>y<span class="token operator">=</span><span class="token string">&quot;group&quot;</span><span class="token punctuation">,</span> x<span class="token operator">=</span><span class="token string">&quot;meanvalue&quot;</span><span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span> palette <span class="token operator">=</span> sns<span class="token punctuation">.</span>color_palette<span class="token punctuation">(</span>bar_color<span class="token punctuation">)</span><span class="token punctuation">,</span>linewidth<span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">,</span> data<span class="token operator">=</span>df<span class="token punctuation">,</span> ax <span class="token operator">=</span> ax2<span class="token punctuation">)</span>
ax2<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> xticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span> <span class="token punctuation">,</span> xlabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;&apos;</span><span class="token punctuation">,</span>title <span class="token operator">=</span> <span class="token string">&apos;&#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE; by seaborn&apos;</span><span class="token punctuation">)</span>
<span class="token comment"># &#x7EDF;&#x4E00;&#x8BBE;&#x7F6E;</span>
plt<span class="token punctuation">.</span>setp<span class="token punctuation">(</span>f<span class="token punctuation">.</span>axes<span class="token punctuation">,</span> ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>tight_layout<span class="token punctuation">(</span>h_pad<span class="token operator">=</span><span class="token number">2</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-7-9.png" width="768">
<p>&#x6709;&#x610F;&#x601D;&#x7684;&#x5730;&#x65B9;&#x5728;&#x4E8E;&#xFF0C;matplotlib&#x7ED8;&#x56FE;&#x53C2;&#x6570;&#x4ECE;bar&#x6362;&#x6210;&#x4E86;barh&#xFF0C;&#x8BBE;&#x7F6E;&#x67F1;&#x5B50;&#x5BBD;&#x5EA6;&#x539F;&#x5148;&#x7528;width&#xFF0C;&#x73B0;&#x5728;&#x6539;&#x6210;&#x4E86;height&#xFF1B;seaborn&#x5462;&#xFF0C;&#x5C31;&#x53EA;&#x8981;&#x628A;x&#x548C;y&#x7684;&#x503C;&#x5BF9;&#x6362;&#x4E00;&#x4E0B;&#x5C31;&#x884C;&#x4E86;&#x3002;&#x5F53;&#x7136;&#x4E86;&#xFF0C;&#x5750;&#x6807;&#x8F74;&#x548C;&#x523B;&#x5EA6;&#x8FD8;&#x662F;&#x8981;&#x81EA;&#x5DF1;&#x8C03;&#x6574;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x4E24;&#x8005;&#x89C4;&#x5F8B;&#x662F;&#x4E00;&#x6837;&#x7684;&#x3002;</p>
<h2 class="mume-header" id="%E6%9F%B1%E7%8A%B6%E5%9B%BE%E8%BF%9B%E9%98%B6">&#x67F1;&#x72B6;&#x56FE;&#x8FDB;&#x9636;</h2>

<h2 class="mume-header" id="%E6%B7%BB%E5%8A%A0%E8%AF%AF%E5%B7%AE%E6%A3%92">&#x6DFB;&#x52A0;&#x8BEF;&#x5DEE;&#x68D2;</h2>

<h3 class="mume-header" id="%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E9%9B%86-1">&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;</h3>

<pre data-role="codeBlock" data-info="python" class="language-python"><span class="token comment"># &#x901A;&#x8FC7;&#x5B57;&#x5178;&#x521B;&#x5EFA;DataFrame</span>
df <span class="token operator">=</span> pd<span class="token punctuation">.</span>DataFrame<span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token string">&apos;group&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group2&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group3&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group4&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;meanvalue&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">18</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;sdvalue&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">2.4</span><span class="token punctuation">,</span> <span class="token number">2.8</span><span class="token punctuation">]</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
  
<span class="token comment"># &#x4E13;&#x4E3A;sns&#x7ED8;&#x56FE;&#x800C;&#x4F5C;</span>
df_sns <span class="token operator">=</span> pd<span class="token punctuation">.</span>DataFrame<span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token string">&apos;group&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group2&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group3&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group4&apos;</span><span class="token punctuation">,</span>
  <span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group2&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group3&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group4&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;meanvalue&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">18</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">,</span> <span class="token number">18</span><span class="token punctuation">,</span> <span class="token number">18</span><span class="token punctuation">,</span> <span class="token number">20.8</span><span class="token punctuation">]</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span> 
</pre><h3 class="mume-header" id="matplotlib%E7%BB%98%E5%88%B6-1">matplotlib&#x7ED8;&#x5236;</h3>

<pre data-role="codeBlock" data-info="python" class="language-python">bar_color <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">&apos;red&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;orange&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;blue&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;green&apos;</span><span class="token punctuation">]</span>
<span class="token comment"># &#x7ED8;&#x5236;&#x4E00;&#x4E2A;&#x7EC4;&#x56FE;&#x5171;&#x4EAB;y&#x8F74;</span>
f<span class="token punctuation">,</span> <span class="token punctuation">(</span>ax1<span class="token punctuation">,</span> ax2<span class="token punctuation">)</span> <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> figsize<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> sharey <span class="token operator">=</span> <span class="token boolean">True</span><span class="token punctuation">)</span>
<span class="token comment"># &#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE;</span>
ax1<span class="token punctuation">.</span>bar<span class="token punctuation">(</span>df<span class="token punctuation">.</span>group<span class="token punctuation">,</span> df<span class="token punctuation">.</span>meanvalue<span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span>
color <span class="token operator">=</span> bar_color<span class="token punctuation">,</span> linewidth <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">)</span>
ax1<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>  xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">,</span> title <span class="token operator">=</span> <span class="token string">&apos;&#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE;&apos;</span><span class="token punctuation">)</span>
ax2<span class="token punctuation">.</span>bar<span class="token punctuation">(</span>df<span class="token punctuation">.</span>group<span class="token punctuation">,</span> df<span class="token punctuation">.</span>meanvalue<span class="token punctuation">,</span> yerr <span class="token operator">=</span> df<span class="token punctuation">.</span>sdvalue<span class="token punctuation">,</span> capsize <span class="token operator">=</span> <span class="token number">4</span><span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span> color <span class="token operator">=</span> bar_color<span class="token punctuation">,</span> lw <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">)</span>
ax2<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>  xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span> title <span class="token operator">=</span> <span class="token string">&apos;&#x67F1;&#x72B6;&#x56FE;+&#x8BEF;&#x5DEE;&#x68D2;&apos;</span><span class="token punctuation">)</span>
<span class="token comment"># &#x7EDF;&#x4E00;&#x8BBE;&#x7F6E;</span>
plt<span class="token punctuation">.</span>setp<span class="token punctuation">(</span>f<span class="token punctuation">.</span>axes<span class="token punctuation">,</span> ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>tight_layout<span class="token punctuation">(</span>h_pad<span class="token operator">=</span><span class="token number">4</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-9-11.png" width="768">
<p>&#x548C;&#x5148;&#x524D;&#x7684;&#x5BF9;&#x6BD4;&#xFF0C;&#x8BEF;&#x5DEE;&#x68D2;&#x4E3B;&#x8981;&#x662F;&#x901A;&#x8FC7;yerr&#x6DFB;&#x52A0;&#xFF0C;&#x4F46;&#x662F;&#x539F;&#x59CB;&#x7684;&#x8BEF;&#x5DEE;&#x68D2;&#x5E3D;&#x5B50;&#x5927;&#x5C0F;&#xFF08;capsize&#xFF09;&#x9ED8;&#x8BA4;&#x4E3A;0.0&#xFF0C;&#x5373;&#x6CA1;&#x6709;&#x5E3D;&#x5B50;&#xFF0C;&#x91C7;&#x7528;capsize&#x8BBE;&#x7F6E;&#x5E3D;&#x5B50;&#x5927;&#x5C0F;&#x3002;&#x552F;&#x4E00;&#x7684;&#x95EE;&#x9898;&#x662F;&#xFF0C;&#x6682;&#x65F6;&#x6CA1;&#x6709;&#x8F83;&#x4E3A;&#x7B80;&#x6613;&#x7684;&#x65B9;&#x6CD5;&#x8BBE;&#x7F6E;&#x8BEF;&#x5DEE;&#x68D2;&#x7684;&#x989C;&#x8272;&#x4E0E;X&#x5206;&#x7EC4;&#x7684;&#x989C;&#x8272;&#x4E00;&#x81F4;&#xFF0C;&#x4F46;&#x8FD9;&#x5BF9;&#x4E8E;&#x5355;&#x4E00;&#x7684;&#x67F1;&#x72B6;&#x56FE;&#x800C;&#x8A00;&#x5176;&#x5B9E;&#x6839;&#x672C;&#x7B97;&#x4E0D;&#x4E0A;&#x4EC0;&#x4E48;&#x95EE;&#x9898;&#xFF0C;&#x5728;&#x540E;&#x9762;&#x7684;&#x8FDB;&#x9636;&#x8FC7;&#x7A0B;&#x4E2D;&#x53EF;&#x80FD;&#x4F1A;&#x7EE7;&#x7EED;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x3002;</p>
<h3 class="mume-header" id="sns%E7%BB%98%E5%88%B6">sns&#x7ED8;&#x5236;</h3>

<pre data-role="codeBlock" data-info="python" class="language-python">bar_color <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">&apos;red&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;orange&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;blue&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;green&apos;</span><span class="token punctuation">]</span>
f<span class="token punctuation">,</span> <span class="token punctuation">(</span>ax1<span class="token punctuation">,</span> ax2<span class="token punctuation">)</span> <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> figsize<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> sharey <span class="token operator">=</span> <span class="token boolean">True</span><span class="token punctuation">)</span>
<span class="token comment"># &#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE;</span>
sns<span class="token punctuation">.</span>barplot<span class="token punctuation">(</span>x<span class="token operator">=</span><span class="token string">&quot;group&quot;</span><span class="token punctuation">,</span> y<span class="token operator">=</span><span class="token string">&quot;meanvalue&quot;</span><span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span> palette <span class="token operator">=</span> sns<span class="token punctuation">.</span>color_palette<span class="token punctuation">(</span>bar_color<span class="token punctuation">)</span><span class="token punctuation">,</span> lw<span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">,</span> data<span class="token operator">=</span>df<span class="token punctuation">,</span> ax <span class="token operator">=</span> ax1<span class="token punctuation">)</span>
ax1<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> yticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span> <span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">,</span> xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span>title <span class="token operator">=</span> <span class="token string">&apos;&#x7B80;&#x5355;&#x67F1;&#x72B6;&#x56FE;&apos;</span><span class="token punctuation">)</span>
<span class="token comment"># &#x67F1;&#x72B6;&#x56FE;+&#x8BEF;&#x5DEE;&#x68D2;</span>
sns<span class="token punctuation">.</span>barplot<span class="token punctuation">(</span>x<span class="token operator">=</span><span class="token string">&quot;group&quot;</span><span class="token punctuation">,</span> y<span class="token operator">=</span><span class="token string">&quot;meanvalue&quot;</span><span class="token punctuation">,</span> errorbar <span class="token operator">=</span> <span class="token string">&apos;sd&apos;</span><span class="token punctuation">,</span> capsize <span class="token operator">=</span> <span class="token number">0.2</span><span class="token punctuation">,</span> errcolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span>edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span> palette <span class="token operator">=</span> sns<span class="token punctuation">.</span>color_palette<span class="token punctuation">(</span>bar_color<span class="token punctuation">)</span><span class="token punctuation">,</span> lw<span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">,</span> data<span class="token operator">=</span>df_sns<span class="token punctuation">,</span> ax <span class="token operator">=</span> ax2<span class="token punctuation">)</span>
ax2<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> yticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span> <span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;&apos;</span><span class="token punctuation">,</span> xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span>title <span class="token operator">=</span> <span class="token string">&apos;&#x67F1;&#x72B6;&#x56FE;+&#x8BEF;&#x5DEE;&#x68D2;&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-10-13.png" width="768">
<p>&#x5173;&#x4E8E;&#x5982;&#x4F55;&#x7ED8;&#x5236;&#x6C34;&#x5E73;&#x7684;&#x5E26;&#x6709;&#x8BEF;&#x5DEE;&#x68D2;&#x7684;&#x67F1;&#x72B6;&#x56FE;&#xFF0C;&#x53EF;&#x4EE5;&#x81EA;&#x5DF1;&#x53BB;&#x5C1D;&#x8BD5;&#x4E00;&#x4E0B;&#xFF0C;&#x4EBA;&#x751F;&#x5C31;&#x8981;&#x4E0D;&#x65AD;&#x5730;&#x8BD5;&#x9519;&#x3002;</p>
<h2 class="mume-header" id="%E5%88%86%E7%BB%84%E6%9F%B1%E7%8A%B6%E5%9B%BE">&#x5206;&#x7EC4;&#x67F1;&#x72B6;&#x56FE;</h2>

<h3 class="mume-header" id="%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E9%9B%86-2">&#x521B;&#x5EFA;&#x6570;&#x636E;&#x96C6;</h3>

<pre data-role="codeBlock" data-info="python" class="language-python"><span class="token comment"># &#x901A;&#x8FC7;&#x5B57;&#x5178;&#x521B;&#x5EFA;DataFrame</span>
df <span class="token operator">=</span> pd<span class="token punctuation">.</span>DataFrame<span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token string">&apos;x&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;group&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;group2&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;t1mean&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;t2mean&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">18</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;t1sd&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;t2sd&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">0.5</span><span class="token punctuation">,</span> <span class="token number">0.8</span><span class="token punctuation">]</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
df
</pre><pre data-role="codeBlock" data-info class="language-"><code>##    x   group  t1mean  t2mean  t1sd  t2sd
## 0  1  group1      10      15     1   0.5
## 1  2  group2      20      18     2   0.8
</code></pre><pre data-role="codeBlock" data-info="python" class="language-python"><span class="token comment">##&#x4E13;&#x4E3A;sns&#x7ED8;&#x56FE;&#x800C;&#x4F5C;</span>
df_sns <span class="token operator">=</span> pd<span class="token punctuation">.</span>DataFrame<span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token string">&apos;group&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;group1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group2&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;group2&apos;</span><span class="token punctuation">,</span><span class="token string">&apos;group2&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;group2&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;Treatment&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">&apos;T1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;T1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;T2&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;T2&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;T1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;T1&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;T2&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;T2&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
  <span class="token string">&apos;value&apos;</span> <span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">9</span><span class="token punctuation">,</span> <span class="token number">11</span><span class="token punctuation">,</span> <span class="token number">19</span><span class="token punctuation">,</span> <span class="token number">21</span><span class="token punctuation">,</span> <span class="token number">14.5</span><span class="token punctuation">,</span> <span class="token number">15.5</span><span class="token punctuation">,</span> <span class="token number">17.4</span><span class="token punctuation">,</span> <span class="token number">18.4</span><span class="token punctuation">]</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
df_sns
</pre><pre data-role="codeBlock" data-info class="language-"><code>##     group Treatment  value
## 0  group1        T1    9.0
## 1  group1        T1   11.0
## 2  group1        T2   19.0
## 3  group1        T2   21.0
## 4  group2        T1   14.5
## 5  group2        T1   15.5
## 6  group2        T2   17.4
## 7  group2        T2   18.4
</code></pre><h3 class="mume-header" id="matplotlib%E7%BB%98%E5%88%B6-2">matplotlib&#x7ED8;&#x5236;</h3>

<pre data-role="codeBlock" data-info="python" class="language-python">fig<span class="token punctuation">,</span> ax <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span>figsize <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
ax<span class="token punctuation">.</span>bar<span class="token punctuation">(</span>df<span class="token punctuation">.</span>x<span class="token operator">-</span><span class="token number">0.125</span><span class="token punctuation">,</span> df<span class="token punctuation">.</span>t1mean<span class="token punctuation">,</span> yerr <span class="token operator">=</span> df<span class="token punctuation">.</span>t1sd<span class="token punctuation">,</span> capsize <span class="token operator">=</span> <span class="token number">4</span><span class="token punctuation">,</span>edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span> color <span class="token operator">=</span> <span class="token string">&apos;red&apos;</span><span class="token punctuation">,</span> lw <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.25</span><span class="token punctuation">,</span> label <span class="token operator">=</span> <span class="token string">&apos;T1&apos;</span><span class="token punctuation">)</span>
ax<span class="token punctuation">.</span>bar<span class="token punctuation">(</span>df<span class="token punctuation">.</span>x<span class="token operator">+</span><span class="token number">0.125</span><span class="token punctuation">,</span> df<span class="token punctuation">.</span>t2mean<span class="token punctuation">,</span> yerr <span class="token operator">=</span> df<span class="token punctuation">.</span>t2sd<span class="token punctuation">,</span> capsize <span class="token operator">=</span> <span class="token number">4</span><span class="token punctuation">,</span> edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span>color <span class="token operator">=</span> <span class="token string">&apos;green&apos;</span><span class="token punctuation">,</span> lw <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.25</span><span class="token punctuation">,</span> label <span class="token operator">=</span> <span class="token string">&apos;T2&apos;</span><span class="token punctuation">)</span>
ax<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span> ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> yticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">,</span>xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>xticks<span class="token punctuation">(</span>df<span class="token punctuation">.</span>x<span class="token punctuation">,</span> df<span class="token punctuation">.</span>group<span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>title<span class="token punctuation">(</span><span class="token string">&apos;&#x5206;&#x7EC4;&#x67F1;&#x72B6;&#x56FE; by matplotlib&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>legend<span class="token punctuation">(</span>title <span class="token operator">=</span> <span class="token string">&apos;Treatment&apos;</span><span class="token punctuation">,</span> loc <span class="token operator">=</span> <span class="token string">&apos;upper left&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-12-15.png" width="384">
<h3 class="mume-header" id="sns%E7%BB%98%E5%88%B6-1">sns&#x7ED8;&#x5236;</h3>

<pre data-role="codeBlock" data-info="python" class="language-python">bar_color <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">&apos;red&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;green&apos;</span><span class="token punctuation">]</span>
fig<span class="token punctuation">,</span> ax <span class="token operator">=</span> plt<span class="token punctuation">.</span>subplots<span class="token punctuation">(</span>figsize <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
sns<span class="token punctuation">.</span>barplot<span class="token punctuation">(</span>x<span class="token operator">=</span><span class="token string">&quot;group&quot;</span><span class="token punctuation">,</span> y<span class="token operator">=</span><span class="token string">&quot;value&quot;</span><span class="token punctuation">,</span> hue <span class="token operator">=</span> <span class="token string">&apos;Treatment&apos;</span><span class="token punctuation">,</span> errorbar <span class="token operator">=</span> <span class="token string">&apos;sd&apos;</span><span class="token punctuation">,</span> capsize <span class="token operator">=</span> <span class="token number">0.1</span><span class="token punctuation">,</span> errcolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span>edgecolor <span class="token operator">=</span> <span class="token string">&apos;black&apos;</span><span class="token punctuation">,</span> palette <span class="token operator">=</span> sns<span class="token punctuation">.</span>color_palette<span class="token punctuation">(</span>bar_color<span class="token punctuation">)</span><span class="token punctuation">,</span> lw<span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> width <span class="token operator">=</span> <span class="token number">0.5</span><span class="token punctuation">,</span> data<span class="token operator">=</span>df_sns<span class="token punctuation">)</span>
ax<span class="token punctuation">.</span><span class="token builtin">set</span><span class="token punctuation">(</span>xlim<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span>ylim <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span> yticks <span class="token operator">=</span> np<span class="token punctuation">.</span>linspace<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span> <span class="token punctuation">,</span> ylabel <span class="token operator">=</span> <span class="token string">&apos;value&apos;</span><span class="token punctuation">,</span> xlabel <span class="token operator">=</span> <span class="token string">&apos;Groups&apos;</span><span class="token punctuation">,</span>title <span class="token operator">=</span> <span class="token string">&apos;&#x5206;&#x7EC4;&#x67F1;&#x72B6;&#x56FE; by sns&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>legend<span class="token punctuation">(</span>title <span class="token operator">=</span> <span class="token string">&apos;Treatment&apos;</span><span class="token punctuation">,</span> loc <span class="token operator">=</span> <span class="token string">&apos;upper left&apos;</span><span class="token punctuation">)</span>
plt<span class="token punctuation">.</span>show<span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><img src="1.python&#x67F1;&#x5F62;&#x56FE;&#x7BC7;_files/figure-html/unnamed-chunk-13-17.png" width="384">

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>